﻿package edu.java.homework.hw10.tests;

import java.util.Scanner;

/* 5.16
 Kakyv shte se otpechata pri izpylnenieto:
 a) pri vyvezhdane na  0;
 b) pri vyvezhdane na chislo razlichno ot 0
 */
public class MyException {
    

    public static void main(String[] args) {
	Scanner input = new Scanner(System.in);
	System.out.print("n= ");
	int n = Math.abs(input.nextInt());
	System.out.println(n);

	int[] a = new int[n];
	for (int i = 0; i < n; i++)
	    a[i] = i * i;
	try {
	    if (a.length == 0)
		return;
	    System.out.println(a[n - 1]);
	} finally {
	    System.out.println("The end");
	}
    }
}

// Answer:
// a) If we input 0, then we will have any Exception because the initialization
// in row 9 is incorrect.

// b) It will be printed a[n-1](the last element of the array) and the
// string "The end".
